package com.moyq5.mvc.maker.test.bean.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.moyq5.mvc.maker.test.bean.enums.AttachScene;
import com.moyq5.mvc.maker.test.bean.enums.AttachType;

/**
 * 附件信息
 * @author Moyq5
 * @date 2018年6月22日
 */
@Entity
@Table(name = "uc_attach")
@DynamicUpdate
public class Attach implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 附件ID
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "attach_id")
	private Long attachId;
	/**
	 * 文件类型
	 */
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "type", nullable = false, columnDefinition="int(1)")
	private AttachType type;
	/**
	 * 文件名称（包含扩展名）
	 */
	@Column(name = "name", length = 100)
	private String name;
	/**
	 * 使用场景
	 */
	@Enumerated(EnumType.ORDINAL)
	@Column(name = "scene", nullable = false, columnDefinition = "int(1)")
	private AttachScene scene;
	/**
	 * 场景ID，对应scene相应表记录ID
	 */
	@Column(name = "scene_id", nullable = false, precision = 20, scale = 0)
	private Long sceneId;
	/**
	 * 服务器
	 */
	@Column(name = "server", nullable = false, length= 200)
	private String server;
	/**
	 * 服务器路径
	 */
	@Column(name = "path", nullable = false, length= 200)
	private String path;
	/**
	 * 访问路径
	 */
	@Column(name = "url", nullable = false, length = 200)
	private String url;
    /**
	 * 添加（注册）时间
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
	}

	public Long getAttachId() {
		return attachId;
	}

	public void setAttachId(Long attachId) {
		this.attachId = attachId;
	}

	public AttachType getType() {
		return type;
	}

	public void setType(AttachType type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public AttachScene getScene() {
		return scene;
	}

	public void setScene(AttachScene scene) {
		this.scene = scene;
	}

	public Long getSceneId() {
		return sceneId;
	}

	public void setSceneId(Long sceneId) {
		this.sceneId = sceneId;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public String getServer() {
		return server;
	}

	public void setServer(String server) {
		this.server = server;
	}
}
